﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Security.Authentication.Identity.Provider;
using Windows.Security.Cryptography;
using Windows.Storage.Streams;

namespace MyHelloWin
{
    class WinHelloInterface
    {
       public async Task<int> RegisterDeviceAsync(string DervicesID, string FriendlyName, string ModelNumber, IBuffer DerviceContext, IBuffer deviceKey, IBuffer authKey)
        {
            // Get a Ibuffer from combinedDataArray
            SecondaryAuthenticationFactorDeviceCapabilities Capabilities = SecondaryAuthenticationFactorDeviceCapabilities.SecureStorage;

            SecondaryAuthenticationFactorRegistrationResult RegistrationResult = await SecondaryAuthenticationFactorRegistration.RequestStartRegisteringDeviceAsync(DervicesID,
                    Capabilities,
                    FriendlyName,
                    ModelNumber,
                    deviceKey,
                    authKey);
            if (RegistrationResult.Status == SecondaryAuthenticationFactorRegistrationStatus.Started) {
                await RegistrationResult.Registration.FinishRegisteringDeviceAsync(DerviceContext);
            }

            return (int)RegistrationResult.Status;
        }

        public async void UnRegisterDeviceAsync(string DervicesID)
        {
            await SecondaryAuthenticationFactorRegistration.UnregisterDeviceAsync(DervicesID);
        }

        public async Task<IReadOnlyList<SecondaryAuthenticationFactorInfo>> EnumDevice()
        {
            IReadOnlyList<SecondaryAuthenticationFactorInfo> DeviceList = await SecondaryAuthenticationFactorRegistration.FindAllRegisteredDeviceInfoAsync(
             SecondaryAuthenticationFactorDeviceFindScope.User);
            return DeviceList;
        }
    }
}
